from django.db import models
from django_ckeditor_5.fields import CKEditor5Field

from apps.common.model import BaseModel


class Article(BaseModel):
    title = models.CharField(max_length=200)
    cover = models.ImageField(verbose_name='封面', upload_to='articles/covers', null=True)
    description = models.CharField(max_length=200, verbose_name='简介绍', null=True)
    content = CKEditor5Field(config_name='extends', verbose_name='正文', null=True)

    class Meta:
        ordering = ['-created_at']
        verbose_name = '文章'
        verbose_name_plural = "文章"

    def __str__(self):
        return self.title
